<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/30
 * Time: 16:14
 */

namespace App\LogicService;

use App\LogicService\Contracts\MedicalComplicationAuxiliaryLogicContract;
use App\Models\MedicalComplicationAuxiliary;


class MedicalComplicationAuxiliaryLogic extends BaseLogic implements MedicalComplicationAuxiliaryLogicContract
{
    public function update($record_id, $value)
    {
        $complicationAuxiliary = MedicalComplicationAuxiliary::firstOrCreate(['record_id' => $record_id, 'name' => $value['name'],'type' => $value['type']]);
        $complicationAuxiliary->left_nature = $value['left_nature'];
        $complicationAuxiliary->right_nature = $value['right_nature'];
        $complicationAuxiliary->type = $value['type'];
        $complicationAuxiliary->remark = $value['remark'];
        $complicationAuxiliary->save();

        return $complicationAuxiliary;
    }

    public function getList($record_id){

        $complications = MedicalComplicationAuxiliary::where('record_id', $record_id)
            ->orderBy('type','asc')
            ->get()
            ->toArray();
        return $complications;
    }
}